//
//  XWNavigationController.swift
//  新浪 weibo
//
//  Created by xuwei on 16/1/18.
//  Copyright © 2016年 xuwei. All rights reserved.
//

import UIKit

class XWNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if childViewControllers.count > 0{
            var title = "返回"
            
            if childViewControllers.count == 1{
                title = childViewControllers.first!.title ?? "返回"
            }
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imgNamed: "navigationbar_back_withtext", title: title, target: self, action: "back")
            viewController.hidesBottomBarWhenPushed = true
            
        }
        super.pushViewController(viewController, animated: true)
    }
    
       @objc private func back(){
        popViewControllerAnimated(true)
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    



}
